using System;
using OhioState.AssetManaged;

namespace OhioState.Graphics.OpenGL
{
    public class LayerTextureHandler : Texture2DHandler, IDisposable
    {
        public LayerTextureHandler(IAssetManaged proxyObject)
            : base(proxyObject)
        {
        }
        protected override void createGLTexture()
        {
            if (_created)
            {
                _realTexture.Dispose();
            }
            //_realTexture = new Texture2DGL(OpenGLPanel.Instance.Width, OpenGLPanel.Instance.Height, _textureProxy.TexelType);
            _realTexture = new Texture2DGL(128, 128, _textureProxy.TexelType);
        }

        protected override void updateGLTexture()
        {
           
        }
               
        //public void Resize(int width, int height)
        //{
        //    if (_created)
        //    {
        //        _realTexture.Dispose();
        //    }
        //    _realTexture = new Texture2DGL(width, height, _textureProxy.TexelType);
        //    this.Create = true;
        //}

        #region IDisposable Members

        public override void Dispose()
        {
            base.Dispose();
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_created)
                {
                    _realTexture.Dispose();
                }
            }
        }

        #endregion
    }
}
